<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.util.*" %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>根据身份证获得年龄</title>
</head>
<body>
 <%!
    public int getAge(String id){
	  int birth=Integer.parseInt(id.substring(6,10));
	  Calendar c=Calendar.getInstance();
	  int year=c.get(Calendar.YEAR);
	  return year-birth;
    }
 %>
 <%
 	 String id1="340123194702157299";
     int nian=getAge(id1);
     
 %>
 <%=id1 %>这个人今年<%=nian %>岁了
 <br/>
 <%-- 
  <%
 	 String id2="340123195102157299";
     int nian2=getAge(id2);
     
 %>
 <%=id2 %>这个人今年<%=nian2 %>岁了
  --%>
</body>
</html>